package cn.iocoder.yudao.module.cook.dal.mysql.cailiao;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.cook.dal.dataobject.cailiao.CailiaoDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.cook.controller.admin.cailiao.vo.*;

/**
 * 食谱材料 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface CailiaoMapper extends BaseMapperX<CailiaoDO> {

    default PageResult<CailiaoDO> selectPage(CailiaoPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<CailiaoDO>()
                .eqIfPresent(CailiaoDO::getParentId, reqVO.getParentId())
                .likeIfPresent(CailiaoDO::getName, reqVO.getName())
                .eqIfPresent(CailiaoDO::getDescription, reqVO.getDescription())
                .eqIfPresent(CailiaoDO::getSort, reqVO.getSort())
                .eqIfPresent(CailiaoDO::getStatus, reqVO.getStatus())
                .orderByDesc(CailiaoDO::getId));
    }

    default List<CailiaoDO> selectList(CailiaoListReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<CailiaoDO>()
               .likeIfPresent(CailiaoDO::getName, reqVO.getName())
               .eqIfPresent(CailiaoDO::getStatus, reqVO.getStatus()));
    }

}